﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Management/Management.master" AutoEventWireup="true"
    CodeFile="ADManager.aspx.cs" Inherits="Management_ADManager" %>

<%@ Import Namespace="Avatar.Company" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table>
        <tr>
            <td>
                <div class="Dialog">
                    <div class="Title">
                        广告列表
                    </div>
                    <div class="Content">
                        广告位：<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1"
                            DataTextField="CategoryName" DataValueField="ID" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AvatarConnectionString %>"
                            SelectCommand="SELECT [ID], [CategoryName] FROM [ADCategory]"></asp:SqlDataSource>
                        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
                            DataKeyNames="ID" ForeColor="#333333" GridLines="None" EmptyDataText="该分类下不包含任何广告内容">
                            <RowStyle BackColor="#EFF3FB" />
                            <Columns>
                                <asp:TemplateField HeaderText="广告标题" SortExpression="Title">
                                    <ItemTemplate>
                                        <%# Eval("Title") %>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="发布者" SortExpression="AdsBy">
                                    <ItemTemplate>
                                        <%# CompanyInformationManager.GetCompanyInformation(Eval("AdsBy").ToString()) != null ? CompanyInformationManager.GetCompanyInformation(Eval("AdsBy").ToString()) .CompanyName: "资料未填写"%>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="开始时间" SortExpression="StartDatetime">
                                    <ItemTemplate>
                                        <%# Eval("StartDatetime") %>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="到期时间" SortExpression="OverDatetime">
                                    <ItemTemplate>
                                        <%# Eval("OverDatetime") %>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="广告状态">
                                    <ItemTemplate>
                                        <%#Convert.ToBoolean(Eval("Open"))==true?"投放中":"已暂停" %>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:Button ID="btn_Edit" runat="server" Text="编辑" CommandArgument='<%# Eval("ID") %>'
                                            OnClick="btn_Edit_Click" />
                                        <asp:Button ID="btn_del" runat="server" Text="删除" CommandArgument='<%# Eval("ID") %>'
                                            OnClick="btn_del_Click" />
                                        <asp:Button ID="btn_OpenClose" runat="server" CommandArgument='<%# Eval("ID") %>'
                                            OnClick="btn_OpenClose_Click" Text="开/关" />
                                        <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" ConfirmText='<%# "确定要删除广告[ "+Eval("Title")+" ]吗？" %>'
                                            Enabled="True" TargetControlID="btn_Del">
                                        </ajaxToolkit:ConfirmButtonExtender>
                                        [<a href="adview.aspx?img=<%# Eval("content") %>" target="_blank">查看</a>]
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                            <EditRowStyle BackColor="#2461BF" />
                            <AlternatingRowStyle BackColor="White" />
                        </asp:GridView>
                    </div>
                </div>
                <div style="height: 5px;">
                </div>
                <asp:Panel ID="Panel1" runat="server" Visible="false">
                    <div class="Dialog">
                        <div class="Title">
                            广告内容编辑
                        </div>
                        <div class="Content">
                            <table>
                                <tr>
                                    <td class="td" style="text-align: right; height: 30px;">
                                        广告位:
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddl_ADCategory" runat="server" DataSourceID="SqlDataSource1"
                                            DataTextField="CategoryName" DataValueField="ID">
                                        </asp:DropDownList>
                                        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:AvatarConnectionString %>"
                                            SelectCommand="SELECT [ID], [CategoryName] FROM [ADCategory]"></asp:SqlDataSource>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td" style="text-align: right; height: 30px;">
                                        <b>广告标题:</b>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txt_Title" runat="server"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td" style="text-align: right; height: 30px;">
                                        <b>广告图片:</b>
                                    </td>
                                    <td>
                                        <table>
                                            <tr>
                                                <td>
                                                    <asp:FileUpload ID="FileUpload1" runat="server" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    如需修改广告图片则在此选择新图片，修改其他项目则此项留空。
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td" style="text-align: right; height: 30px;">
                                        广告内容链接:</td>
                                    <td>
                                        <asp:TextBox ID="txt_URL" runat="server" Width="350px"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td" style="text-align: right; height: 30px;">
                                        <b>图片尺寸:</b>
                                    </td>
                                    <td>
                                        <asp:Label ID="lbl_WidthHeight" runat="server"></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td" style="text-align: right; height: 30px;">
                                        <b>延期投放:</b>
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddl_Day" runat="server">
                                            <asp:ListItem Value="0">不延期</asp:ListItem>
                                            <asp:ListItem Value="30">30天</asp:ListItem>
                                            <asp:ListItem Value="60">60天</asp:ListItem>
                                            <asp:ListItem Value="90">90天</asp:ListItem>
                                        </asp:DropDownList>
                                        <asp:HiddenField ID="txt_ADID" runat="server" />
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" style="text-align: center;">
                                        <asp:Button ID="btn_Next" runat="server" CssClass="Button" Text="确定" OnClick="btn_Next_Click" />
                                        &nbsp;<asp:Button ID="btn_Cancel" runat="server" CssClass="Button" OnClick="btn_Cancel_Click"
                                            Text="取消" />
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" style="text-align: center;">
                                        <asp:Label ID="lbl_Error" runat="server" ForeColor="Red" EnableViewState="false"></asp:Label>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </asp:Panel>
                <div style="text-align: left;">
                    注意：由于启用缓存机制，广告系统的某些修改可能不会马上显示出来，请耐心等待30分钟后再查看相应修改。</div>
            </td>
        </tr>
    </table>
</asp:Content>
